package com.dyl.api.sms.factory;

import com.dyl.common.core.RR;

import com.dyl.api.sms.RemoteSmsService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
* 微服务调用失败
* */

public class RemoteSmsFallbackFactory implements FallbackFactory<RemoteSmsService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteSmsFallbackFactory.class);
    @Override
    public RemoteSmsService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteSmsService()
        {
            @Override
            public RR sendSmsPhone(String phone) {
                return RR.error("发送短信失败").code(400);
            }

            @Override
            public RR querySmsPhone(String phone, String codes) {
                return RR.error("获取短信失败").code(400);
            }

        };
    }


}
